ActiveReports 9
Rendering to Word
Show AllShow All
Hide AllHide All

MS Word is one of the formats to which you can export ActiveReports from the Viewer. You can use the WordRenderingExtension to render your report in Microsoft® Word 2003 and 2007 formats.

In order to render your report in MS Word, add reference to the following assemblies in the project:

The following steps provide an example of rendering a report in the Word format.

  1. In Visual Studio, create a new Windows Forms Application or open an existing one.
  2. On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
  3. Add the following code inside the Form_Load event.
Visual Basic.NET code. Paste INSIDE the Form Load event.
Copy Code
' Provide the page report you want to render.
Dim report As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\Sample_PageReport.rdlx"))
Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report)

' Create a output directory
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyWord")
outputDirectory.Create()

' Provide settings for your rendering output.
Dim wordSetting As New GrapeCity.ActiveReports.Export.Word.Page.Settings()
Dim setting As GrapeCity.ActiveReports.Extensibility.Rendering.ISettings = wordSetting

' Set the rendering extension and render the report.
Dim wordRenderingExtension As New GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension()
Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
reportDocument.Render(wordRenderingExtension, outputProvider, wordSetting)
C# code. Paste INSIDE the Form Load event.
Copy Code
// Provide the page report you want to render.
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.ActiveReports.Document.PageDocument(report);

// Create a output directory
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyWord");
outputDirectory.Create();

// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Word.Page.Settings wordSetting = new GrapeCity.ActiveReports.Export.Word.Page.Settings(); 
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = wordSetting;

//Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension wordRenderingExtension = new GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
reportDocument.Render(wordRenderingExtension, outputProvider, wordSetting);

Word Rendering Properties

ActiveReports offers several options to control how reports render to Microsoft® Word.

Property Description
Author Enter the name of the author to appear in the File Properties dialog of the Microsoft® Word application on the Summary tab in the Author field.
BaseUrl Enter a base URL for any relative hyperlinks used in the report. This value appears in the File Properties dialog of the Microsoft® Word application on the Summary tab in the Hyperlink base field.
Generator Set the identity of the document generator in a meta-data file stamp. The default value is "Created using ActiveReports."
PageHeight Enter a value in inches (i.e. 11 in) to set the height of the report's pages. This value overrides the report's original settings.
PageWidth Enter a value in inches (i.e. 8.5 in) to set the width of the report's pages. This value overrides the report's original settings.
Title Enter the document’s title. This value appears in the File Properties dialog of the Microsoft® Word application on the Summary tab in the Title field.
UseMhtOutput Set True or False value to indicate whether Mht output is to be used for the resultant Word document or not.

Limitations

Although background colors for controls export to Word documents, background colors for sections such as Body and Page Header or Footer do not.

Interactivity

Reports rendered in a Word format supports both Bookmarks and Hyperlinks. However, if visibility toggling (like in a drill-down report) is essential to your report, it is recommended to use the HTML rendering extension. And If a Document map is essential to your report, it is recommended to use the PDF rendering extension.

See Also

Concepts

 

 


Copyright © 2014 GrapeCity, inc. All rights reserved

Support Forum